#!/usr/bin/env php
<?php

$dir = __DIR__ . '/dist';
$file = $dir . '/dbdiff.phar';

@unlink($file);
@mkdir($dir, 0755, true);

$phar = new Phar($file);

$phar->startBuffering();

$phar->buildFromDirectory(__DIR__, '/src\/.*|vendor\/.*|dbdiff\.php/');

$stub = $phar->createDefaultStub('dbdiff.php');
$stub = "#!/usr/bin/env php \n" . $stub;
$phar->setStub($stub);

$phar->compress(Phar::GZ);
$phar->stopBuffering();

chmod($file, 0755);

echo 'Build successful: dist/dbdiff.phar' . PHP_EOL;
